
-- =============================================
-- Author:		Christopher Navarro
-- Create date: 8/12/12
-- Description:	Auto Genera un blog en el sistema.
-- =============================================
CREATE TRIGGER trg_GenerarBlog 
   ON   dbo.trol_usuario
   AFTER INSERT
AS 
BEGIN
	DECLARE @id_usuario int	--variable para el ID del usuario.
	DECLARE @id_rol int --variable para el rol del usuario.
	
	SET @id_usuario = (SELECT id_usuario FROM inserted )--sets valriable @id_usuario.
	SET @id_rol = (SELECT id_rol FROM inserted)

	IF @id_rol = 1 or @id_rol = 2
		BEGIN
		
			INSERT INTO tblog(id_usuario)
			VALUES (@id_usuario)
		
		END
	
END
GO
